Skip to content

Conversation

@kssumin
Copy link

@kssumin kssumin commented Mar 9, 2025

This PR adds support for negated parameters in Spring MVC mappings when used with Feign clients.
It resolves issue #1134 where negated parameters in @RequestMapping were not supported, causing IllegalArgumentException when shared interfaces were used between server and client.

Changes:

  • Added allowNegatedParams configuration option to FeignClientProperties
  • Modified SpringMvcContract to silently skip negated parameters when this feature is enabled
  • Added tests for both enabled and disabled scenarios
  • Updated documentation to explain the new feature and configuration options

Use case:

When sharing interfaces between server and client code, negated parameters (e.g. params = {"!expiration"}) are useful on the server side to disambiguate mappings. With this change, clients can now use these shared interfaces by setting spring.cloud.openfeign.client.config.feignName.allowNegatedParams=true.

The implementation silently ignores negated parameters when building the client request, which aligns with the expected behavior since negated parameters are constraints used only on the server side.

@OlgaMaciaszek

ryanjbaxter and others added 30 commits August 7, 2024 11:22
…cloud#1045)

Bumps [com.google.protobuf:protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.25.3 to 3.25.4.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl)
- [Commits](protocolbuffers/protobuf@v3.25.3...v3.25.4)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…g-cloud#1042)

Bumps [com.fasterxml.jackson.dataformat:jackson-dataformat-smile](https://github.com/FasterXML/jackson-dataformats-binary) from 2.17.1 to 2.17.2.
- [Commits](FasterXML/jackson-dataformats-binary@jackson-dataformats-binary-2.17.1...jackson-dataformats-binary-2.17.2)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-smile
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
updated-dependencies:
- dependency-name: "@antora/collector-extension"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [@springio/asciidoctor-extensions](https://github.com/spring-io/asciidoctor-extensions) from 1.0.0-alpha.10 to 1.0.0-alpha.13.
- [Changelog](https://github.com/spring-io/asciidoctor-extensions/blob/main/CHANGELOG.adoc)
- [Commits](spring-io/asciidoctor-extensions@v1.0.0-alpha.10...v1.0.0-alpha.13)

---
updated-dependencies:
- dependency-name: "@springio/asciidoctor-extensions"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…d#1063)

Bumps [antora](https://gitlab.com/antora/antora) from 3.2.0-alpha.4 to 3.2.0-alpha.6.
- [Changelog](https://gitlab.com/antora/antora/blob/main/CHANGELOG.adoc)
- [Commits](https://gitlab.com/antora/antora/compare/v3.2.0-alpha.4...v3.2.0-alpha.6)

---
updated-dependencies:
- dependency-name: antora
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Conflicts:
#	docs/package.json
* Make Content-Encoding configurable

A new configuration property was added to make the Content-Encoding
configurable when using the feign request compression. The default
values are the same as the previous hardcoded values.

Closes issue 1048
Bumps commons-io:commons-io from 2.16.1 to 2.17.0.

---
updated-dependencies:
- dependency-name: commons-io:commons-io
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…cloud#1090)

Bumps [com.google.protobuf:protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.25.4 to 3.25.5.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl)
- [Commits](protocolbuffers/protobuf@v3.25.4...v3.25.5)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
spring-cloud#1087)

Bumps [com.google.protobuf:protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.25.4 to 3.25.5.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl)
- [Commits](protocolbuffers/protobuf@v3.25.4...v3.25.5)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [io.github.openfeign:feign-bom](https://github.com/openfeign/feign) from 13.3 to 13.4.
- [Release notes](https://github.com/openfeign/feign/releases)
- [Changelog](https://github.com/OpenFeign/feign/blob/master/CHANGELOG.md)
- [Commits](OpenFeign/feign@13.3...13.4)

---
updated-dependencies:
- dependency-name: io.github.openfeign:feign-bom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* polishing feignClientsRegistrar

* update the date in the license and add author
…g-cloud#1097)

Bumps [com.fasterxml.jackson.dataformat:jackson-dataformat-smile](https://github.com/FasterXML/jackson-dataformats-binary) from 2.17.2 to 2.18.0.
- [Commits](FasterXML/jackson-dataformats-binary@jackson-dataformats-binary-2.17.2...jackson-dataformats-binary-2.18.0)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-smile
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copy link
Collaborator

@OlgaMaciaszek OlgaMaciaszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @kssumin, thanks for submitting the PR. Have added some comments - please address them. Also, please re-submit your PR against 4.1.x instead of main, so that we can include it in earlier supported release trains as well.

this.allowNegatedParams = allowNegatedParams;
}

public SpringMvcContract(List<AnnotatedParameterProcessor> annotatedParameterProcessors,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should set the allowNegatedParams field from properties here.

}

@Test
void testAllowNegatedParams() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same naming convention as other tests in this class, starting with should...

}

@Test
void testAllowNegatedParams() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove throws Exception

}

@Test
void testDisallowNegatedParams() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same naming convention as other tests in this class, starting with should...,

assertThat(data.get(1).bodyIndex()).isEqualTo(0);
}

@Test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test where properties are used to change this. This kind of test could be added, for example, to the FeignClientFactoryBeanIntegrationTests class.

@OlgaMaciaszek OlgaMaciaszek linked an issue Mar 12, 2025 that may be closed by this pull request
@OlgaMaciaszek
Copy link
Collaborator

Fixes gh-1134.

@kssumin kssumin changed the base branch from main to 4.1.x March 13, 2025 02:19
@OlgaMaciaszek
Copy link
Collaborator

@kssumin the base branch cannot be just changed. The easiest way to correctly change the branch would be to close this PR and create a new one by applying your commits to the 4.1.x branch.

@kssumin
Copy link
Author

kssumin commented Mar 13, 2025

@kssumin the base branch cannot be just changed. The easiest way to correctly change the branch would be to close this PR and create a new one by applying your commits to the 4.1.x branch.

Got it, I'll close this PR and create a new one based on the 4.1.x branch.

@kssumin kssumin closed this Mar 13, 2025
@OlgaMaciaszek
Copy link
Collaborator

Hello @kssumin, actually I'd really like to ensure that we get this fix into today's 2024.0.1 release, so I'm going to cherry-pick your commits and finish it up quickly. Thank you for working on this issue. I'm going to remove your @author tag, since we only accept full name and surname. Please provide your full name and surname and then I will add your @author tag to the modified classes.

@OlgaMaciaszek
Copy link
Collaborator

@kssumin, actually, upon further consideration, since this issue is a bug and not an enhancement, I think we should stop throwing the exception altogether - just add some logging and ignore the parameter on Feign contract processing, so I will add that change now instead. While we'll not be including the proposed changes at this point, seeing your PR has helped in deciding on the fix for the issue, so thank you for your work on this issue.

@kssumin
Copy link
Author

kssumin commented Mar 13, 2025

Hello @kssumin, actually I'd really like to ensure that we get this fix into today's 2024.0.1 release, so I'm going to cherry-pick your commits and finish it up quickly. Thank you for working on this issue. I'm going to remove your @author tag, since we only accept full name and surname. Please provide your full name and surname and then I will add your @author tag to the modified classes.

My full name is Kim Su-min. My surname is Kim.

@kssumin, actually, upon further consideration, since this issue is a bug and not an enhancement, I think we should stop throwing the exception altogether - just add some logging and ignore the parameter on Feign contract processing, so I will add that change now instead. While we'll not be including the proposed changes at this point, seeing your PR has helped in deciding on the fix for the issue, so thank you for your work on this issue.

Thank you for the update. I understand your decision to handle this issue with a logging approach. I'm glad my PR helped in finding the direction for solving the problem. I look forward to actively contributing to the project in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IllegalArgumentException: Negated params are not supported

10 participants